import $util from "@/utils/index.js"
import $api from "@/api/index.js"
import {
	req
} from '@/utils/req.js';
export default {
	state: {
		pageActive: false,
		activeIndex: 0,
		tabList: [
			{
				title: '婚恋交友',
				id: 2
			}, {
				title: '其他活动',
				id: 1,
				// number: 10
			},
		],
		param: {
			p: 1,
			type: 2,
		},
		list: [],
		last_page: 1,
		current_page: 1,
		haveOperItem: false
	},
	mutations: {
		updateActivityItem(state, item) {
			let {
				key,
				val
			} = item
			state[key] = val
		}
	},
	actions: {
		async getActivitylist({
			commit,
			state
		}, param) {
			let d = await $api.user.getActivitylist(param)
			let oldList = state.list;
			let newList = d;
			let list = {}
			if (param.p == 1) {
				list = newList;
			} else {
				newList = oldList.data.concat(newList)
				list = newList;
			}
			for (var i = 0; i < list.length; i++) {
				let item = list[i];
				// debugger
				if(item.activity_photo && item.activity_photo.length > 0){
					item.image = item.activity_photo[0].imageurl
				}
			}
			
			// debugger activity_photo
			commit('updateActivityItem', {
				key: 'list',
				val: list
			})
		},
	}
}
